//
// Created by Administrator on 2021/5/15.
//
#include <stack>
#include <iostream>

using namespace std;

class MyQueue {
private:
    stack<int> st1, st2;
public:
    /** Initialize your data structure here. */
    MyQueue() {
        while (!st1.empty()) st1.pop();
        while (!st2.empty()) st2.pop();
    }

    /** Push element x to the back of queue. */
    void push(int x) {
        st1.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    int pop() {
        int top = peek();
        if (top != -1){
            st2.pop();
        }
        return top;

    }

    /** Get the front element. */
    int peek() {
        if (st2.empty()) {
            while (!st1.empty()) {
                st2.push(st1.top());
                st1.pop();
            }
        }
        if (st2.empty()) return -1;
        else {
            return st2.top();
        }
    }

    /** Returns whether the queue is empty. */
    bool empty() {
        return st1.empty() and st2.empty();
    }
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */

int main() {
    auto obj = new MyQueue;
    obj->push(1);
    obj->push(2);
    cout << obj->peek() << endl;
    cout << obj->pop() << endl;
    cout << obj->empty() << endl;
    return 0;
}